
import {parseDate} from '@/utils/index'

// 文件上传
// export function uploadFile(data) {
//   let params = new FormData();
//   params.append("file",data.file);
//   return request({
//     url:'/common/backend_upload',
//     method:'post',
//     data:params
//   })
// }

export function getAge(birthDate) {
  if(birthDate == null){
    return 0;
  }

  if(typeof birthDate == "string"){
    birthDate = parseDate(birthDate);
  }

  return new Date().getFullYear() - birthDate.getFullYear();
}


let sexOptions = [
  // {
  //   value: '0',
  //   label: '未知性别'
  // },
    {
      value: '1',
      label: '男性'
    }, {
      value: '2',
      label: '女性'
    }, {
      value: '3',
      label: '未说明性别'
    },
]

export function getSexOptions() {
  return sexOptions
}

export function getSex(sexId) {
  for(let item of sexOptions){
    if(item.value == sexId){
      return item.label;
    }
  }
  return "未知性别"
}


let doctorTitleOptions=[{
  value: '231',
  label: '主任医生'
},
  {
    value: '232',
    label: '副主任医生'
  }, {
    value: '233',
    label: '主治医师'
  }, {
    value: '234',
    label: '医师'
  },]

export function getDoctorTitleOptions() {
  return doctorTitleOptions
}

export function getDoctorTitle(titleId) {
  for(let item of doctorTitleOptions){
    if(item.value == titleId){
      return item.label;
    }
  }
  return ""
}

//处方订单状态  订单状态 1：待支付，2：待配药 3：待发货，4：已发货，5：已完成，-1：已关闭 -2：退款中，-3：已退款
let prescriptionOrderStatusOptions = [
  {
  value: '1',
  label: '待支付'
  },
  {
    value: '2',
    label: '待配药'
  },{
    value: '3',
    label: '待发货'
  }, {
    value: '4',
    label: '已发货'
  }, {
    value: '5',
    label: '已完成'
  },{
    value: '-1',
    label: '已关闭'
  },{
    value: '-2',
    label: '退款中'
  },{
    value: '-3',
    label: '已退款'
  },
]


export function getPrescriptionOrderStatusOptions() {
  return prescriptionOrderStatusOptions
}

export function getPrescriptionOrderStatus(id) {
  for(let item of prescriptionOrderStatusOptions){
    if(item.value == id){
      return item.label;
    }
  }
  return "未知状态"
}

//处方类型
let rxTypeOptions = [
  {
    value: '1',
    label: '药品处方'
  },
  {
    value: '2',
    label: '检验检查处方'
  },
]


export function getRxTypeOptionsOptions() {
  return rxTypeOptions
}

export function getRxType(id) {
  for(let item of rxTypeOptions){
    if(item.value == id){
      return item.label;
    }
  }
  return "未知状态"
}


//问诊订单状态
let inquiryOrderStatusOptions = [
  {
    value: '1',
    label: '待支付'
  },{
    value: '2',
    label: '待就诊'
  },  {
    value: '3',
    label: '就诊中'
  },
  {
    value: '4',
    label: '已完成'
  },  {
    value: '-1',
    label: '超时取消'
  },
  {
    value: '-2',
    label: '医生无法接诊取消'
  },{
    value: '-3',
    label: '结束问诊并退款取消'
  }
]


export function getInquiryOrderStatusOptions() {
  return inquiryOrderStatusOptions
}

export function getInquiryOrderStatus(id) {
  for(let item of inquiryOrderStatusOptions){
    if(item.value == id){
      return item.label;
    }
  }
  return "未知状态"
}


//问诊订单状态    问诊类型 1：图文问诊，2：视频问诊
let inquiryTypeOptions = [
  {
    value: '1',
    label: '图文问诊'
  },
  {
    value: '2',
    label: '视频问诊'
  },
]


export function getInquiryTypeOptions() {
  return inquiryTypeOptions
}

export function getInquiryType(id) {
  for(let item of inquiryTypeOptions){
    if(item.value == id){
      return item.label;
    }
  }
  return "未知类型"
}


//问诊进程状态    1：未开始，2：病情提问，3：医助接诊，4：等待医生接诊，5：问诊中，6：结束问诊。
let inquiryProcessStatusOptions = [
  {
    value: '1',
    label: '未开始'
  },
  {
    value: '2',
    label: '病情提问'
  },  {
    value: '3',
    label: '医助接诊'
  },  {
    value: '4',
    label: '等待医生接诊'
  },  {
    value: '5',
    label: '问诊中'
  }, {
    value: '6',
    label: '结束问诊'
  },
]


export function getInquiryProcessStatusOptions() {
  return inquiryProcessStatusOptions
}

export function getInquiryProcessStatus(id) {
  for(let item of inquiryProcessStatusOptions){
    if(item.value == id){
      return item.label;
    }
  }
  return "未知进程"
}

//用户与患者之间的关系
let relationOptions = [
  {
    value: '0',
    label: '本人或户主'
  },  {
    value: '1',
    label: '配偶'
  },
  {
    value: '2',
    label: '儿子'
  },  {
    value: '3',
    label: '女儿'
  },  {
    value: '4',
    label: '孙儿'
  },  {
    value: '5',
    label: '父母'
  },{
    value: '6',
    label: '祖父母'
  },{
    value: '7',
    label: '兄弟姐妹'
  },{
    value: '8',
    label: '亲友'
  },
]


export function getRelationOptions() {
  return relationOptions
}

export function getRelation(id) {
  for(let item of relationOptions){
    if(item.value == id){
      return item.label;
    }
  }
  return "未知关系"
}


//医生积分变更类型
let integralChangeTypeOptions = [
  {
    value:"1",
    label:"邀请医生",
    enable:false,
  },
  {
    value:"2",
    label:"药品处方",
    enable:false,
  },
  {
    value:"3",
    label:"检验检查处方",
    enable:false,
  },
  {
    value:"4",
    label:"问诊订单",
    enable:false,
  },
  {
    value:"5",
    label:"退款扣减",
    enable:true,
  },
  {
    value:"6",
    label:"人工处理",
    enable:true,
  },
  {
    value:"7",
    label:"活动奖励",
    enable:true,
  },
  {
    value:"8",
    label:"续方问诊",
    enable:true,
  },

]

export function getIntegralChangeTypeOptions() {
  return integralChangeTypeOptions
}

export function getIntegralChangeType(id) {
  for(let item of integralChangeTypeOptions){
    if(item.value == id){
      return item.label;
    }
  }
  return "未知关系"
}

//1：待支付，2：待配药 3：待发货，4：已发货，5：已完成，-1：已取消
//处方订单状态
let prescriptionStatusOptions = [
  {
    value:null,
    label:"全部",
  },
  {
    value:"1",
    label:"待支付",
  },
  {
    value:"2",
    label:"待配药",
  },
  {
    value:"3",
    label:"待发货",
  },
  {
    value:"4",
    label:"已发货",
  },
  {
    value:"5",
    label:"已完成",
  },
  {
    value:"-1",
    label:"已关闭",
  },
]

export function getPrescriptionStatusOptions() {
  return prescriptionStatusOptions
}

export function getPrescriptionStatus(id) {
  for(let item of prescriptionStatusOptions){
    if(item.value == id){
      return item.label;
    }
  }
  return "未知状态"
}

//1：药品处方，2：检验检查处方
//处方订单状态
let prescriptionTypeOptions = [
  {
    value:null,
    label:"全部",
  },
  {
    value:"1",
    label:"药品处方",
  },
  {
    value:"2",
    label:"检验检查处方",
  },
]

export function getPrescriptionTypeOptions() {
  return prescriptionTypeOptions
}

export function getPrescriptionType(id) {
  for(let item of prescriptionTypeOptions){
    if(item.value == id){
      return item.label;
    }
  }
  return "未知类型"
}


//1：到院自取，2：物流到家
//处方订单状态
let pickupTypeOptions = [
  {
    value:null,
    label:"全部",
  },
  {
    value:"1",
    label:"到院自取",
  },
  {
    value:"2",
    label:"物流到家",
  },
]

export function getPickupTypeOptions() {
  return pickupTypeOptions
}

export function getPickupType(id) {
  for(let item of pickupTypeOptions){
    if(item.value == id){
      return item.label;
    }
  }
  return "未知类型"
}


//上下架状态 0：下架，1：上架
//上线状态
let basePriceChannelStatusOptions = [
  {
    value:null,
    label:"全部",
  },
  {
    value:"0",
    label:"下架",
  },
  {
    value:"1",
    label:"上架",
  },
]

export function getBasePriceChannelStatusOptions() {
  return basePriceChannelStatusOptions
}

export function getBasePriceChannelStatus(id) {
  for(let item of basePriceChannelStatusOptions){
    if(item.value == id){
      return item.label;
    }
  }
  return "未知状态"
}


//药品使用频次
let direOptions = [
  {
    value:null,
    label:"全部",
  },{
    value:"bid",
    label:"2次/d",
  },{
    value:"biw",
    label:"2次/周",
  },{
    value:"Hs",
    label:"睡前服用",
  },{
    value:"q12h",
    label:"1次/12h",
  },{
    value:"q1h",
    label:"1次/h",
  },{
    value:"q3h",
    label:"1次/3h",
  },{
    value:"q6h",
    label:"1次/6h",
  },{
    value:"q8h",
    label:"1次/8h",
  },{
    value:"qd",
    label:"1次/d",
  },{
    value:"qid",
    label:"4次/d",
  },{
    value:"qod",
    label:"隔天1次",
  },{
    value:"qw",
    label:"1次/周",
  },{
    value:"st",
    label:"立即服用",
  },{
    value:"tid",
    label:"3次/日",
  }
]

export function getDireOptions() {
  return direOptions;
}

export function getDire(id) {
  for(let item of direOptions){
    if(item.value == id){
      return item.label;
    }
  }
  return "未知方式"
}

//药品用法

let freqOptions = [
  {
    value:null,
    label:"全部",
  },{
    value:"1",
    label:"口服",
  },{
    value:"2",
    label:"直肠给药",
  },{
    value:"3",
    label:"舌下给药",
  },{
    value:"4",
    label:"注射给药",
  },{
    value:"401",
    label:"皮下注射",
  },{
    value:"402",
    label:"皮内注射",
  },{
    value:"403",
    label:"肌肉注射",
  }
]

export function getFreqOptions() {
  return freqOptions;
}

export function getFreq(id) {
  for(let item of freqOptions){
    if(item.value == id){
      return item.label;
    }
  }
  return "未知状态"
}


let itemLevelOptions = [
{
    value:"1",
    label:"A",
  },{
    value:"2",
    label:"B",
  },{
    value:"3",
    label:"C",
  },{
    value:"4",
    label:"D",
  },{
    value:"5",
    label:"E",
  }
]

export function getItemLevelOptions() {
  return itemLevelOptions;
}

export function getItemLevel(id) {
  for(let item of itemLevelOptions){
    if(item.value == id){
      return item.label;
    }
  }
  return ""
}
